package org.example.springbootpra1.demos.util;

import lombok.Data;

@Data
public class Result<T> {

    private String message;

    private Integer code;

    private Boolean isOK;

    private Integer start;

    private Integer pageSize;

    private Integer total;

    private T data;

    public Result(String message, Integer code, boolean isOK, T data) {
        this.message = message;
        this.code = code;
        this.isOK = isOK;
        this.data = data;
    }

    public Result(String message, Integer code, boolean isOK, T data, Integer start, Integer pageSize, Integer total) {
        this.message = message;
        this.code = code;
        this.isOK = isOK;
        this.data = data;
        this.start = start;
        this.pageSize = pageSize;
        this.total = total;
    }

    public Result(String message, Integer code, boolean isOK) {
        this.message = message;
        this.code = code;
        this.isOK = isOK;
    }

    public static <T> Result<T> Success(String message,T data) {
        return new Result<T>(message, 1,true, data);
    }

    public static <T> Result<T> Success(String message) {
        return new Result<T>(message, 1,true);
    }

    public static <T> Result<T> error(String message) {
        return new Result<T>(message, 0,false);
    }

}